#--
# Interface to tool configuration
#
# Author:: Lachlan Donald (mailto:lachlan@ljd.cc)
# Copyright:: Copyright (c) 2007-2008 Lachlan Donald
# License:: MIT
#++

require 'yaml'
require 'ostruct'

module Cloudwire

	class YamlConfiguration
		def initialize(file)
			@yaml = YAML.load_file(file)
		end
		def method_missing(methodname)
			return @yaml[methodname.to_s]
		end
	end

	class Configuration < YamlConfiguration
	end

	class Types < YamlConfiguration
		def initialize(file)
			super(file)
			@types = @yaml.keys.inject({}) do |hash,key|
				hash[key] = OpenStruct.new @yaml[key]
				hash
			end
		end

		def has_type?(type_key)
			@types.has_key?(type_key)
		end

		def type_keys
			@types.keys
		end

		def type(type_key)
			@types[type_key]
		end
	end

end
